package com.example.shop_2207.database

import android.app.Application
import androidx.room.Room

class MyDbUtils {
    companion object{
        private lateinit var myDatabase: MyDatabase

        fun init(application: Application){
            myDatabase = Room.databaseBuilder(application,MyDatabase::class.java,"2207a.db")
                .allowMainThreadQueries()//允许主线程上执行
                .build()
        }

        fun getDb() = myDatabase
        //两个方法结果相同
       /* fun getDb:MyDatabase{
            return myDatabase
        }*/
    }
}